import { PaginationComponent } from './components/pagination/pagination.component';
import { DecimalPipe } from './pipes/decimal.pipe';
import { CurrencyPipe } from './pipes/currency.pipe';
import { TrustHtmlPipe } from './pipes/trust-html.pipe';
import { TrustStylePipe } from './pipes/trust-style.pipe';
import { TrustScriptPipe } from './pipes/trust-script.pipe';
import { TrustUrlPipe } from './pipes/trust-url.pipe';
import { TrustResourceUrlPipe } from './pipes/trust-resource-url.pipe';

import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgModule, ModuleWithProviders, Optional } from '@angular/core';
import { ProgressBarComponent } from './components/progress-bar/progress-bar.component';
import { ButtonComponent } from './components/button/button.component';
import { RippleButtonDirective } from './directives/ripple-button.directive';
import { NumberToCharacterPipe } from './pipes/number-to-character.pipe';
import { TimeToMinutePipe } from './pipes/time-to-minute.pipe';
import { LazyImgComponent } from './components/lazy-img/lazy-img.component';
import { DeviceSizeDirective } from './directives/device-size.directive';
import { SharedConfig, SharedConfigService } from './config/shared-config.service';
import { MinuteSecondPipe } from './pipes/minute-second.pipe';
import { WeixinSizeDirective } from './directives/weixin-size.directive';


@NgModule({
    imports: [
        CommonModule,
        InfiniteScrollModule
    ],
    providers: [
        SharedConfigService
    ],
    declarations: [
        CurrencyPipe,
        DecimalPipe,
        TrustHtmlPipe,
        TrustStylePipe,
        TrustScriptPipe,
        TrustUrlPipe,
        TrustResourceUrlPipe,
        MinuteSecondPipe,
        PaginationComponent,
        ProgressBarComponent,
        ButtonComponent,
        RippleButtonDirective,
        NumberToCharacterPipe,
        TimeToMinutePipe,
        LazyImgComponent,
        DeviceSizeDirective,
        WeixinSizeDirective
    ],
    exports: [
        CommonModule,
        FormsModule,
        InfiniteScrollModule,
        CurrencyPipe,
        DecimalPipe,
        TrustHtmlPipe,
        TrustStylePipe,
        TrustScriptPipe,
        TrustUrlPipe,
        TrustResourceUrlPipe,
        MinuteSecondPipe,
        PaginationComponent,
        ProgressBarComponent,
        LazyImgComponent,
        ButtonComponent,
        RippleButtonDirective,
        NumberToCharacterPipe,
        TimeToMinutePipe,
        DeviceSizeDirective,
        WeixinSizeDirective
    ]
})
export class CommonShareModule {

    static forRoot(config: SharedConfig): ModuleWithProviders {
        return {
            ngModule: CommonShareModule,
            providers: [
                { provide: SharedConfig, useValue: config }
            ]
        };
    }
}
